package com.genesis.yunnanji.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.util.MultiTypeDelegate;
import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.ExplorationRoomBean;
import com.genesis.yunnanji.config.GenesisApiConfig;

import java.util.List;

/**
 * 创建日期：2018/10/26 00269:54
 * 作者：Kite
 * 描述：体验馆适配器
 */
public class ExplorationRoomAdapter extends BaseQuickAdapter<ExplorationRoomBean.ResultBean.ListBean.DataBean, BaseViewHolder> {

    private Context context;

    public ExplorationRoomAdapter(@Nullable List<ExplorationRoomBean.ResultBean.ListBean.DataBean> data, Context context) {
        super(data);
        this.context = context;
        setMultiTypeDelegate(new MultiTypeDelegate<ExplorationRoomBean.ResultBean.ListBean.DataBean>() {
            @Override
            protected int getItemType(ExplorationRoomBean.ResultBean.ListBean.DataBean entity) {
                return entity.getItemType();
            }
        });
        getMultiTypeDelegate().registerItemType(0, R.layout.item_room_text)
                .registerItemType(1, R.layout.item_group)
                .registerItemType(2, R.layout.item_exp_room_v);
    }

    @Override
    protected void convert(BaseViewHolder helper, ExplorationRoomBean.ResultBean.ListBean.DataBean item) {
        switch (item.getItemType()) {
            case 0:
                helper.setText(R.id.tv_title,item.getTitle());
                break;
            case 1:
                helper.setText(R.id.tv_name,item.getTitle());
                Glide.with(context).load(GenesisApiConfig.PIC_HOST + item.getCover_img()).into((ImageView) helper.getView(R.id.iv_img));
                break;
            case 2:
                Glide.with(context).load(GenesisApiConfig.PIC_HOST + item.getCover_img()).into((ImageView) helper.getView(R.id.iv_supitem_iv));
                helper.setText(R.id.tv_supitem_title,item.getTitle());
                helper.setText(R.id.tv_supitem_address,item.getAddress());
                helper.setText(R.id.tv_supitem_phone,item.getPhone());
                break;
        }
    }
}
